<?php
function validarRecover() {
	global $login;
	$flags = array();
	if (isset($_POST['email']) && (!empty($_POST['email']))) {
		if (validarEmailCorrecto($_POST['email'])) $login->set('usuarios','email',$_POST['email']); 
		else $flags = push_validate($flags,'email','Formato invalido de email');
	} else $flags = push_validate($flags,'email','Debe escribir un email');
	return $flags;
}
function push_validate($array,$item,$message) {
	$arr_fail = array('item' => $item,'message' => $message);
	array_push($array, $arr_fail);
	return $array;
}
function validarEmailCorrecto($email) {
	$pattern = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/';
	if ((!empty($email)) && (preg_match($pattern, $email))) return true;
	else return false;
}
?>